namespace SuppKids.Migrator.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.DailyMenus",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        DayOfWeek = c.Int(nullable: false),
                        WeekNumber = c.Int(nullable: false),
                        MenuType = c.Int(nullable: false),
                        MealType = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Dishes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 255),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.ProductConsumptions",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Type = c.Int(nullable: false),
                        Value = c.Double(nullable: false),
                        Dish_Id = c.Int(),
                        Product_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Dishes", t => t.Dish_Id)
                .ForeignKey("dbo.Products", t => t.Product_Id)
                .Index(t => t.Dish_Id)
                .Index(t => t.Product_Id);
            
            CreateTable(
                "dbo.Products",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 255),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.ProductAtStorages",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        DeliveryDate = c.DateTime(nullable: false),
                        Bill = c.String(maxLength: 4000),
                        DeliveryAmount = c.Double(nullable: false),
                        ConsumptAmount = c.Double(nullable: false),
                        Supplier = c.String(maxLength: 4000),
                        Recipient = c.String(maxLength: 4000),
                        Product_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Products", t => t.Product_Id)
                .Index(t => t.Product_Id);
            
            CreateTable(
                "dbo.DishDailyMenus",
                c => new
                    {
                        Dish_Id = c.Int(nullable: false),
                        DailyMenu_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Dish_Id, t.DailyMenu_Id })
                .ForeignKey("dbo.Dishes", t => t.Dish_Id, cascadeDelete: true)
                .ForeignKey("dbo.DailyMenus", t => t.DailyMenu_Id, cascadeDelete: true)
                .Index(t => t.Dish_Id)
                .Index(t => t.DailyMenu_Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.ProductAtStorages", "Product_Id", "dbo.Products");
            DropForeignKey("dbo.ProductConsumptions", "Product_Id", "dbo.Products");
            DropForeignKey("dbo.ProductConsumptions", "Dish_Id", "dbo.Dishes");
            DropForeignKey("dbo.DishDailyMenus", "DailyMenu_Id", "dbo.DailyMenus");
            DropForeignKey("dbo.DishDailyMenus", "Dish_Id", "dbo.Dishes");
            DropIndex("dbo.ProductAtStorages", new[] { "Product_Id" });
            DropIndex("dbo.ProductConsumptions", new[] { "Product_Id" });
            DropIndex("dbo.ProductConsumptions", new[] { "Dish_Id" });
            DropIndex("dbo.DishDailyMenus", new[] { "DailyMenu_Id" });
            DropIndex("dbo.DishDailyMenus", new[] { "Dish_Id" });
            DropTable("dbo.DishDailyMenus");
            DropTable("dbo.ProductAtStorages");
            DropTable("dbo.Products");
            DropTable("dbo.ProductConsumptions");
            DropTable("dbo.Dishes");
            DropTable("dbo.DailyMenus");
        }
    }
}
